package testDemo.Test8;

import java.io.*;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("127.0.0.1", 10066);

//        BufferedReader bis = new BufferedReader(new FileReader("a.txt"));
//        BufferedWriter bos = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
//        String line;
//        while((line=bis.readLine())!=null) {
//            bos.write(line);
//            bos.newLine();
//            bos.flush();
//        }
        DataInputStream dis=new DataInputStream(new BufferedInputStream(new FileInputStream("a.txt")));
        DataOutputStream dos=new DataOutputStream(new BufferedOutputStream(s.getOutputStream()));
        byte[] bytes = new byte[1024];
        int line;
        String name = dis.readUTF();
        dos.writeUTF(name);
        dos.flush();
        while((line=dis.read(bytes))!=-1){
            dos.write(bytes,0,line);
            dos.flush();
        }
        s.close();
    }
}
